<template>
  <div>
    <a-card :bordered="false">
      <a-divider orientation="left">税金单据</a-divider>
      <a-descriptions bordered size="small" :column="2">
        <a-descriptions-item label="开票单位" :span="2">
          {{formItem.invoiceUnit.invoiceunitName}}
        </a-descriptions-item>
        <a-descriptions-item label="收款银行">
          {{formItem.invoiceUnitBank.bankName}}
        </a-descriptions-item>
        <a-descriptions-item label="收款账户">
          {{formItem.invoiceUnitBank.bankNo}}
        </a-descriptions-item>
        <a-descriptions-item label="发票类型">
          {{formItem.invoicePayment.invoiceType}}
        </a-descriptions-item>
        <a-descriptions-item label="开票日期">
          {{formItem.invoicePayment.invoiceDate}}
        </a-descriptions-item>
        <a-descriptions-item label="附件" :span="2">
          <f-images :value="formItem.invoicePaymentImage"></f-images>
        </a-descriptions-item>
        <a-descriptions-item label="备注">
          {{formItem.invoicePayment.remark}}
        </a-descriptions-item>
      </a-descriptions>
      <a-divider orientation="left">返款单信息</a-divider>
      <a-descriptions bordered size="small" :column="2">
        <a-descriptions-item label="单位名称">
          {{formItem.supplierName}}
        </a-descriptions-item>
        <a-descriptions-item label="纳税识别号">
          {{formItem.taxNumber}}
        </a-descriptions-item>
        <a-descriptions-item label="开户行">
          {{formItem.bankName}}
        </a-descriptions-item>
        <a-descriptions-item label="卡号">
          {{formItem.bankNo}}
        </a-descriptions-item>
        <a-descriptions-item label="联系人">
          {{formItem.linkMan}}
        </a-descriptions-item>
        <a-descriptions-item label="联系电话">
          {{formItem.linkTel}}
        </a-descriptions-item>
        <a-descriptions-item label="地址">
          {{formItem.address}}
        </a-descriptions-item>
        <a-descriptions-item label="附件" :span="2">
          <f-images :value="formItem.paymentImage"></f-images>
        </a-descriptions-item>
        <a-descriptions-item label="备注">
          {{formItem.remark}}
        </a-descriptions-item>
      </a-descriptions>

      <a-divider orientation="left">返款明细</a-divider>
      <f-table ref="table" rowKey="invoiceDetailsId" :columns="columns" :scroll="{x:true}" :multiple="false" handler="yesInvoiceDetailsPageListHandler" :operator="operator" :autoLoad="false" :params="queryParam" :api="api.bod">
      </f-table>
    </a-card>
  </div>
</template>
<script>

  import api from './../js/api'

  export default {
    name: 'RefundDetails',
    components: {},
    data() {
      let me = this
      //操作按钮
      let operator = []
      let companyId = this.$store.getters.companyId
      let columns=[
        {
          title: '#',
          width: '60',
          align: 'center',
          customRender: (text, record, index) => index + 1
        },
        {
          title: '单号',
          align: 'center',
          dataIndex: 'orderNo'
        },
        {
          title: '发货日期',
          align: 'center',
          dataIndex: 'sendDate'
        },
        {
          title: '供货方',
          align: 'center',
          dataIndex: 'supplierName'
        },
        {
          title: '购货方',
          align: 'center',
          dataIndex: 'customName'
        },
        {
          title: '商品名称',
          align: 'center',
          dataIndex: 'drugsName'
        },
        {
          title: '规格',
          align: 'center',
          dataIndex: 'drugsSpec'
        },
        {
          title: '数量',
          align: 'center',
          dataIndex: 'saleNum'
        },
        {
          title: '单价',
          align: 'center',
          dataIndex: 'salePrice'
        },
        {
          title: '应返金额',
          align: 'center',
          needTotal: true,
          dataIndex: 'supplierRetable'
        }
      ];
      if(companyId==4){
        columns.push( {
          title: '应返金额2',
          align: 'center',
          needTotal: true,
          dataIndex: 'supplierRetable2'
        })
      }
      return {
        api: Object.assign(api, this.api),
        //列表初始化查询参数
        queryParam: {},
        invoiceDetailsModal: false,
        supplierRetable: 0,
        supplierId: '',
        selectIds: '',
        modalTitle: '开票申请确认',
        params1: {
          formulaType: 5
        },
        params2: {
          bankType: 1
        },
        formItem: this.getFormItem(),
        // 表头
        columns: columns,
        operator: operator
      }
    },
    created() {
    },
    methods: {
      getFormItem() {
        return {
          invoiceId: '',
          companyId: '',
          supplierId: '',
          invoiceUnit: {},
          invoiceUnitBank:{},
          invoicePayment:{},
          taxAmount: '',
          invoiceAmount: '',
          invoiceDate: '',
          bankId: null,
          invoiceType: null,
          userId: '',
          invoiceState: '',
          remark: ''
        }
      },
      setData(data) {
        this.formItem = this.getFormItem()
        if (data && data.paymentId) {
          let params = {
            paymentId: data.paymentId,
            handlerName: 'refundPaymentGetHandler'
          }
          this.http.get(this, {
            url: this.api.payment.get,
            params: params,
            success: function(me, data) {
              me.formItem = data
              me.loaded = true
            }
          })
          this.queryParam.paymentId = data.parentId
          this.$refs['table'].refresh(false)
        }
      }
    }
  }
</script>
